import type * as Tables from "./type.ts"
import { request } from "@/http/axios.ts"

/** 增 */
export function createCardDataApi(data: Tables.AddForm): Promise<Tables.ApiResponse> {
  return request({
    url: "/parking/card",
    method: "post",
    data
  })
}
// 续费
export function renewCardDataApi(data: Tables.RechargeForm): Promise<Tables.ApiResponse> {
  return request({
    url: "/parking/card/recharge",
    method: "POST",
    data
  })
}
/** 删 */
export function deleteCardDataApi(ids: string): Promise<Tables.ApiResponse> {
  return request({
    url: `/parking/card/${ids}`,
    method: "delete"
  })
}

/** 改 */
export function updateCardDataApi(data: Tables.AddForm): Promise<Tables.ApiResponse> {
  return request({
    url: "/parking/card/edit",
    method: "put",
    data
  })
}
export function getMonthCardDetailDataApi(id: number): Promise<Tables.ApiResponse<Tables.CardItem & { rechargeList: any[] }>> {
  return request ({
    url: `/parking/card/${id}`
  })
}
/** 查 */
export function getMonthCardDataApi(params: Tables.SearchParams): Promise<Tables.PageResponse<Tables.CardItem>> {
  return request({
    url: "/parking/card/list",
    method: "get",
    params
  })
}
